package com.ajaxw.io;

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

public class Writer {
	private PrintWriter pw;

	private Writer(String encoding) {
		OutputStreamWriter osw = null;
		try {
			osw = new OutputStreamWriter(System.out, encoding);
		} catch (UnsupportedEncodingException e) {
			System.out.println("WARN - Encoding not support: " + encoding);
			osw = new OutputStreamWriter(System.out);
		}
		this.pw = new PrintWriter(osw);
	}

	public static Writer getWriter(String encoding) {
		return new Writer(encoding);
	}

	public void write(String msg) {
		this.pw.write(msg);
	}
}
